Wintec tes format (#835)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Sat, 29 Jan 2022 15:27:03 +0000 (08:27 -0700)
committerGitHub <noreply@github.com>
Sat, 29 Jan 2022 15:27:03 +0000 (08:27 -0700)
* convert wintec_tes for Format class.

* add new h file.

* add default init.

CMakeLists.txt
GPSBabel.pro
vecs.h
wintec_tes.cc
wintec_tes.h [new file with mode: 0644]

index 97b91874b50f018e88bb1dea5c647950684da3c9..fe1e5bcf3e24fa7e8692cbaf52a99bb7ee949172 100644 (file)
@@ -259,6 +259,7 @@ set(HEADERS
   unicsv.h
   units.h
   vecs.h
+  wintec_tes.h
   xcsv.h
   xmlgeneric.h
   jeeps/garminusb.h
index bdb346a6f36e8ad029abd93c1b396e28ebb367a3..01ac589664b921b273f9c532c4702863f52be244 100644 (file)
@@ -246,6 +246,7 @@ HEADERS =  \
   unicsv.h \
   units.h \
   vecs.h \
+  wintec_tes.h \
   xcsv.h \
   xmlgeneric.h \
   jeeps/garminusb.h \
diff --git a/vecs.h b/vecs.h
index 4a06a8a702fd8c4df5f7af9eb0038244c21e2d70..c5f0d7a2b88e4405625819be946d45fe1a6d627a 100644 (file)
--- a/vecs.h
+++ b/vecs.h
@@ -48,6 +48,7 @@
 #include "skytraq.h"
 #include "subrip.h"
 #include "unicsv.h"
+#include "wintec_tes.h"
 #include "xcsv.h"
 
 extern ff_vecs_t geo_vecs;
@@ -122,7 +123,6 @@ extern ff_vecs_t mmo_vecs;
 extern ff_vecs_t v900_vecs;
 extern ff_vecs_t enigma_vecs;
 extern ff_vecs_t teletype_vecs;
-extern ff_vecs_t wintec_tes_vecs;
 extern ff_vecs_t format_garmin_xt_vecs;
 extern ff_vecs_t mapbar_track_vecs;
 extern ff_vecs_t f90g_track_vecs;
@@ -315,7 +315,7 @@ private:
   LegacyFormat teletype_fmt {teletype_vecs};
   SkytraqfileFormat skytraq_ffmt;
   MinihomerFormat miniHomer_fmt;
-  LegacyFormat wintec_tes_fmt {wintec_tes_vecs};
+  WintecTesFormat wintec_tes_fmt;
   SubripFormat subrip_fmt;
   LegacyFormat format_garmin_xt_fmt {format_garmin_xt_vecs};
   GarminFitFormat format_fit_fmt;
index bef8fca28fd8e72606fa25abd0f2238b8e64ee4f..f9de12d9f9e56f920e43ff7045edb533370583ed 100644 (file)
 
  */
 
-#include "defs.h"
+#include "wintec_tes.h"
 
-#define MYNAME "wintec_tes"
+#include <ctime>                   // for time_t, tm
+#include <cstring>                 // for memset
+
+#include "defs.h"                  // for Waypoint, mkgmtime, track_add_head, track_add_wpt, waypt_add, route_head
 
-static gbfile* fin;
 
-static void
-wintec_tes_rd_init(const QString& fname)
+#define MYNAME "wintec_tes"
+
+void
+WintecTesFormat::rd_init(const QString& fname)
 {
   fin = gbfopen(fname, "r", MYNAME);
 }
 
-static void
-wintec_tes_rd_deinit()
+void
+WintecTesFormat::rd_deinit()
 {
   gbfclose(fin);
 }
 
-static time_t
-wintec_date_to_time(uint32_t w)
+time_t
+WintecTesFormat::wintec_date_to_time(uint32_t w)
 {
   struct tm tm;
   memset(&tm, 0, sizeof(tm));
@@ -53,8 +57,8 @@ wintec_date_to_time(uint32_t w)
   return mkgmtime(&tm);
 }
 
-static void
-wintec_tes_read()
+void
+WintecTesFormat::read()
 {
   auto* trk = new route_head;
   track_add_head(trk);
@@ -91,28 +95,3 @@ wintec_tes_read()
     track_add_wpt(trk, wpt);
   }
 }
-
-static
-QVector<arglist_t> wintec_tes_args = {
-};
-
-ff_vecs_t wintec_tes_vecs = {
-  ff_type_file,
-  {
-    ff_cap_read                        /* waypoints */,
-    ff_cap_read                        /* tracks */,
-    ff_cap_none                        /* routes */
-  },
-  wintec_tes_rd_init,
-  nullptr,
-  wintec_tes_rd_deinit,
-  nullptr,
-  wintec_tes_read,
-  nullptr,
-  nullptr,
-  &wintec_tes_args,
-  CET_CHARSET_ASCII, 0                 /* ascii is the expected character set */
-  /* not fixed, can be changed through command line parameter */
-  , NULL_POS_OPS,
-  nullptr
-};
diff --git a/wintec_tes.h b/wintec_tes.h
new file mode 100644 (file)
index 0000000..6daf960
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+
+    Wintec tes support.
+
+    Copyright (C) 2010  Robert Lipe, robertlipe+source@gpsbabel.org
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+ */
+#ifndef WINTEC_TES_H_INCLUDED_
+#define WINTEC_TES_H_INCLUDED_
+
+#include <QString>   // for QString
+#include <QVector>   // for QVector
+
+#include <cstdint>   // for uint32_t
+#include <ctime>     // for time_t
+
+#include "defs.h"    // for ff_cap, arglist_t, ff_cap_read, CET_CHARSET_ASCII, ff_cap_none, ff_type, ff_type_file
+#include "format.h"  // for Format
+#include "gbfile.h"  // for gbfile
+
+
+class WintecTesFormat : public Format
+{
+public:
+  QVector<arglist_t>* get_args() override
+  {
+    return &wintec_tes_args;
+  }
+
+  ff_type get_type() const override
+  {
+    return ff_type_file;
+  }
+
+  QVector<ff_cap> get_cap() const override
+  {
+    /*         waypoints,      tracks,      routes */
+    return { ff_cap_read, ff_cap_read, ff_cap_none };
+  }
+
+  QString get_encode() const override
+  {
+    return CET_CHARSET_ASCII;
+  }
+
+  int get_fixed_encode() const override
+  {
+    return 0;
+  }
+
+  void rd_init(const QString& fname) override;
+  void read() override;
+  void rd_deinit() override;
+
+private:
+  /* Member Functions */
+
+  static time_t wintec_date_to_time(uint32_t w);
+
+  /* Data Members */
+
+  gbfile* fin{};
+
+  QVector<arglist_t> wintec_tes_args = {
+  };
+
+};
+#endif // WINTEC_TES_H_INCLUDED_